package com.kefu.call.vo;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.kefu.basic.model.BasicStatusConfig;
import com.kefu.call.model.CallAgentAuxStatus;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractInsertVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

@Data
@ApiModel("呼叫自定义状态")
public class CallStatusConfigInsertVo extends AbstractInsertVo<BasicStatusConfig> {
    @NotEmpty
    @ApiModelProperty(value = "状态名")
    private String statusName;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "状态图标")
    private String statusIcon;

    @Override
    public BasicStatusConfig convert() {
        BasicStatusConfig info = BeanUtil.toBean(this, BasicStatusConfig.class);
        info.setStatusType(2);
        info.setTenantId(KefuContext.getTid());
        info.setUpdateTime(DateUtil.current());
        info.setUpdateUser(KefuContext.getUid());
        info.setId(IdUtil.simpleUUID());
        return info;
    }

    public CallAgentAuxStatus convertCall(Integer statusCode) {
        CallAgentAuxStatus callAgentAuxStatus = new CallAgentAuxStatus();
        callAgentAuxStatus.setOid(statusCode);
        callAgentAuxStatus.setVal(statusName);
        callAgentAuxStatus.setValenable("是");
        callAgentAuxStatus.setSort(statusCode);
        callAgentAuxStatus.setKeyid(String.valueOf(statusCode));
        return callAgentAuxStatus;
    }
}
